<?php
if (!defined('BASEPATH')) {
	exit('No direct script access allowed');
}

class form_dinamis extends CI_Controller {

	function __construct() {
		parent::__construct();
		$this->load->library('breadcrumb');
		$this->load->model('m_auth');
		$this->load->model('m_form_dinamis');
	}

	function index() {
		$this->layout->set_include('css', 'themes/apotek/css/olide-custom.css');
		$this->layout->set_include('js', 'themes/apotek/js/olide-custom.js', 'header');
		$this->layout->set_include('js', 'themes/general/bundle/jquery_validation/jquery.validate.min.js', 'header');
		$this->layout->set_include('js', 'themes/general/bundle/jquery_validation/jquery.validate.min.js', 'header');
		$this->layout->set_include('js', 'themes/general/bundle/jquery_validation/localization/messages_id.min.js', 'header');
		$this->layout->set_include('js', 'themes/general/bundle/select2/select2.min.js', 'header');
		$this->layout->set_include('css', 'themes/general/bundle/select2/select2.min.css');
		$data['obat'] = $this->m_form_dinamis->get_all();
		$this->layout->theme('apotek','form_dinamis/index',$data);
	}

	public function editable(){
		$this->layout->set_include('css', 'themes/apotek/bundle/bootstrap3-editable/css/bootstrap-editable.css');
		$this->layout->set_include('js', 'themes/apotek/bundle/bootstrap3-editable/js/bootstrap-editable.js');
		$this->layout->set_include('js', 'themes/apotek/js/olide-custom.js');
		
		$this->layout->theme('apotek','form_dinamis/editable');
	}

	public function update_max_dosis(){
		$KdObat = $this->input->post('pk');
		$dataUpdate = array(
			'MaxDosis' => $this->input->post('value'), 
			);

		$this->m_form_dinamis->update_max_dosis($KdObat, $dataUpdate);
	}

	public function chart(){
		# code...
	}
}
